//
//  CellYongHuHu.m
//  SeeTheWorld
//
//  Created by dllo on 16/3/3.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CellYongHuHu.h"
#import "PCH.pch"
#import "ModelYongHuHu.h"
#import <UIImageView+WebCache.h>


@interface CellYongHuHu ()

@property (nonatomic, retain)UILabel *labelOfTitle;
@property (nonatomic, retain)UILabel *labelOfUsername;
@property (nonatomic, retain)UIImageView *imageOfTouXiang;


@end

@implementation CellYongHuHu

- (void)dealloc {
    [_labelOfTitle release];
    [_labelOfUsername release];
    [_imageOfTouXiang release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
        
    }
    
    return self;
    
}

- (void)createSubviews {
    
    self.imageOfTouXiang = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageOfTouXiang];
    [_imageOfTouXiang release];
    
    self.labelOfUsername = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelOfUsername];
    [_labelOfUsername release];
    self.labelOfUsername.dk_textColorPicker = DKColorWithRGB(0x343434, 0xffffff);

    self.labelOfTitle = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelOfTitle];
    [_labelOfTitle release];
    self.labelOfTitle.font = [UIFont systemFontOfSize:14];
    self.labelOfTitle.dk_textColorPicker = DKColorWithRGB(0x343434, 0xffffff);


}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageOfTouXiang.frame = CGRectMake(10, 10, scWIDTH / 4, scHEIGHT - 20);
    self.imageOfTouXiang.layer.cornerRadius = scWIDTH / 4 / 3;
    self.imageOfTouXiang.layer.masksToBounds = YES;
    
    self.labelOfUsername.frame = CGRectMake(10 + scWIDTH / 4 + 5, 10, scWIDTH / 4 * 3 - 20, (scHEIGHT - 30) / 2);
    self.labelOfTitle.frame = CGRectMake(10 + scWIDTH / 4  + 5, 10 + (scHEIGHT - 30) / 2 + 10, scWIDTH / 4 * 3 - 20, (scHEIGHT - 30) / 2);
}


- (void)passModel:(ModelYongHuHu *)model {
    
    [self.imageOfTouXiang sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:[UIImage imageNamed:@"1f178a82b9014a90e9109296ad773912b31beeeb"]];
    self.labelOfUsername.text = model.username;

    self.labelOfTitle.text = [NSString stringWithFormat:@"%@  | 去过%@个国家, %@个城市", model.title, model.countries, model.cities];
    
}

@end
